package admin

import (
	"context"
	"server/internal/service"

	"github.com/gogf/gf/v2/errors/gerror"

	"server/api/admin/system"
)

func (c *ControllerSystem) AdminChangePassword(ctx context.Context, req *system.AdminChangePasswordReq) (res *system.AdminChangePasswordRes, err error) {
	res = new(system.AdminChangePasswordRes)
	if req.Password != req.ConfirmPassword {
		err = gerror.New("密码不一致")
		return
	}
	err = service.SystemUser().ChangePassword(ctx, req.Id, req.Password)
	return
}
